package server.comm;

import java.nio.channels.SocketChannel;
import java.util.ArrayList;
import java.util.List;

import common.packets.Packet;

/**
 * @author  mickek
 */
public class PacketEnvelope {

	private PacketEnvelope(){
		
	}
	
	/**
	 * @uml.property  name="packets"
	 * @uml.associationEnd  multiplicity="(0 -1)"
	 */
	private Packet[] packets;
	
	private List<SocketChannel> recipients = new ArrayList<SocketChannel>(10);
	
	public PacketEnvelope( List<SocketChannel> _reciepients, Packet[] _packets ) {
		packets = _packets;
		recipients.addAll(_reciepients);
	}
	
	public PacketEnvelope( List<SocketChannel> reciepients, Packet packet ){
		this(reciepients, new Packet[]{packet});
	}
	
	public PacketEnvelope( SocketChannel _recipient, Packet _packet){
		packets = new Packet[]{_packet};
		recipients.add(_recipient);
	}
	
	public PacketEnvelope( SocketChannel _recipient, Packet[] _packets){
		packets = _packets;
		recipients.add(_recipient);
	}
	
	/**
	 * @return
	 * @uml.property  name="recipients"
	 */
	public List<SocketChannel> getRecipients(){
		return recipients;
	}
	
	/**
	 * @return
	 * @uml.property  name="packets"
	 */
	public Packet[] getPackets(){
		return packets;
	}
	
	
}
